<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>ECharts 示例</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<!--标准mui.css-->
		<link rel="stylesheet" href="../../css/mui.min.css">
		<!--App自定义的css-->
		<!-- <link rel="stylesheet" type="text/css" href="../css/app.css" /> -->
		<style>
			.chart {
				height: 200px;
				margin: 0px;
				padding: 0px;
			}
			h5 {
				margin-top: 30px;
				font-weight: bold;
			}
			h5:first-child {
				margin-top: 15px;
			}
			.mui-card {
				margin: 15px;
				border-radius: 10px;
			}
		</style>
		<script src="../../js/mui.min.js"></script>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">chart（EChart图表）</h1>
		</header>
		<div class="mui-content">
			<div class="mui-content-padded">
				<h5>收支比较</h5>
				<div class="chart" id="lineChart"></div>
				<div class="mui-card">
					<!--页眉，放置标题-->
					<div class="mui-card-header">
						<div id="">
							<select name="" style="margin-left: 100px;">
								<option selected="selected">选择月份</option>
								<option value="1">1月</option>
								<option value="2">2月</option>
								<option value="3">3月</option>
								<option value="4">4月</option>
								<option value="5">5月</option>
							</select>
							<p>毛利： ￥<b style="color: #000000;">1234</b></p>
							<p>支出： ￥<b style="color: #000000;">123</b></p>
						</div>
					</div>
					<!--页脚，放置补充信息或支持的操作-->
					<div class="mui-card-footer">利润：￥<b style="color: #000000;">123</b></div>
				</div>
				<h5>财务支出分布</h5>
				<div class="chart" id="pieChart"></div>
			</div>
		</div>

		<script src="../../js/echarts-all.js"></script>
		<script>
			var shouru = [105.6, 145.6, 135.6, 125.6, 115.6, 176.7, 135.6, 162.2, 162.2, 162.2, 162.2, 162.2];
			//var shouru = [105.6, 145.6, 135.6, 125.6,115.6, 176.7, 135.6, 162.2];
			var zhichu = [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3];
			var zhichubing = [{
				value: 335,
				name: '水电费'
			}, {
				value: 310,
				name: '房租费'
			}, {
				value: 234,
				name: '人工费'
			}, {
				value: 135,
				name: '其他'
			}];

			var getOption = function(chartType) {
				var chartOption = chartType == 'pie' ? {
					calculable: false,
					series: [{
						name: '访问来源',
						type: 'pie',
						radius: '65%',
						center: ['50%', '50%'],
						data: zhichubing
					}]
				} : {
					legend: {
						data: ['收入', '支出']
					},
					grid: {
						x: 35,
						x2: 10,
						y: 30,
						y2: 25
					},
					toolbox: {
						show: false,
						feature: {
							mark: {
								show: true
							},
							dataView: {
								show: true,
								readOnly: false
							},
							magicType: {
								show: true,
								type: ['line', 'bar']
							},
							restore: {
								show: true
							},
							saveAsImage: {
								show: true
							}
						}
					},
					calculable: false,
					xAxis: [{
						type: 'category',
						data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
					}],
					yAxis: [{
						type: 'value',
						splitArea: {
							show: true
						}
					}],
					series: [{
						name: '收入',
						type: chartType,
						data: shouru
					}, {
						name: '支出',
						type: chartType,
						data: zhichu
					}]
				};
				return chartOption;
			};
			var byId = function(id) {
				return document.getElementById(id);
			};
			var lineChart = echarts.init(byId('lineChart'));
			lineChart.setOption(getOption('line'));
			var pieChart = echarts.init(byId('pieChart'));
			pieChart.setOption(getOption('pie'));
			byId("echarts").addEventListener('tap', function() {
				var url = this.getAttribute('data-url');
				plus.runtime.openURL(url);
			}, false);
		</script>
	</body>

</html>